#if !defined(AFX_SERVERSOCKETTHREAD_H__7405DFC2_48C2_4314_86EC_3B71ED55E3DC__INCLUDED_)
#define AFX_SERVERSOCKETTHREAD_H__7405DFC2_48C2_4314_86EC_3B71ED55E3DC__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ServerSocketThread.h : header file
//

class Packet;
class CServerSocket;

/////////////////////////////////////////////////////////////////////////////
// CServerSocketThread thread

class CServerSocketThread : public CWinThread
{
	DECLARE_DYNCREATE(CServerSocketThread)
protected:
	CServerSocketThread();           // protected constructor used by dynamic creation

	// Attributes
public:
	SOCKET m_hSocket;
	std::list<Packet *> m_PacketsIn;
	std::list<Packet *> m_PacketsOut;
	CMutex m_mutexPacketsIn;
	CMutex m_mutexPacketsOut;
	// 2005-8-20
	// login time;
	int m_nLoginTime;

protected:
	CServerSocket * m_pSocket;

	// Operations
public:
	void DeleteInstance();
	void AddPacketReceived(Packet * pPacket);
	void AddPacketToSend(Packet * pPacket);
	Packet * TakePacketToSend();
	Packet * TakePacketReceived();
	bool IsSocketHandleMatched(SOCKET hSocket) const;
	void SetbStop(bool bStop);

	// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CServerSocketThread)
public:
	virtual BOOL InitInstance();
	virtual int ExitInstance();
	//}}AFX_VIRTUAL

	// Implementation
protected:
	virtual ~CServerSocketThread();

	// Generated message map functions
	//{{AFX_MSG(CServerSocketThread)
	// NOTE - the ClassWizard will add and remove member functions here.
	//}}AFX_MSG
	afx_msg LRESULT OnExitSocketThread(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnSendTo(WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_SERVERSOCKETTHREAD_H__7405DFC2_48C2_4314_86EC_3B71ED55E3DC__INCLUDED_)
